package com.eiokey.tobebest;

import android.annotation.SuppressLint;
import android.os.Bundle;

import com.eiokey.baselibrary.annotation.BindingVariable;
import com.eiokey.baselibrary.annotation.GetLayoutId;
import com.eiokey.baselibrary.annotation.ViewModel;
import com.eiokey.baselibrary.base.ui.BaseActivity;
import com.eiokey.baselibrary.utils.LogUtils;
import com.eiokey.linkbus.annotation.OnMessage;
import com.eiokey.tobebest.base.MessageId;
import com.eiokey.tobebest.databinding.ActivityMainBinding;
import com.eiokey.tobebest.mvvm.viewmodel.MainViewModel;

/**
 * description 主入口
 * use
 * param
 * return
 * @author JetQiao
 * @date 2021/7/21  1:29 下午
 */
@SuppressLint("NonConstantResourceId")
@GetLayoutId(R.layout.activity_main)
@ViewModel(MainViewModel.class)
@BindingVariable(BR.viewmodel)
public class MainActivity extends BaseActivity<MainViewModel, ActivityMainBinding> {


    @Override
    protected void initView(Bundle bundle) {

        mDataBinding.tvMainTest.setText("----------");

        mDataBinding.btnMainTestBus.setOnClickListener(v -> {
            LogUtils.d("点击button");
            mViewModel.changeBtnText();
            mViewModel.doNoting();
        });
    }


    @OnMessage(value = MessageId.MESSAGE_BUTTON_TEST)
    public void getTextTest(String data) {

        LogUtils.d("=========" + data);
        mDataBinding.tvMainTest.setText(data);
    }
}